<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('base/css', TEMPLATE_INCLUDEPATH)) : (include template('base/css', TEMPLATE_INCLUDEPATH));?>
<style>
    .joininformation{border:1px solid #ccc;width:100%;padding:15px;float:left;margin-right:15px}
    .joininformation-settings{border:1px solid #ccc;width:270px;padding:15px;float:left;}
    .joininformation input{border:1px dotted #ccc;outline: none;}
    .joininformation-item{float:left}
    .joininformation-title, .joininformation-box, .joininformation-tip{display:inline-block;width:48%;box-sizing: border-box;cursor: pointer;}
    .joininformation-box{text-align: center}
    .joininformation-title{margin-right:1%}
    .joininformation-tip{width:99%}
    .joininformation-settings-name{display:inline-block;width:30%}
    .joininformation-settings-value{display:inline-block;width:59%}
    .joininformation-action{text-align: left}
    .joininformation-extend{float:left;text-align: center;margin-left:30px}
    .joininformation-extend input{text-align: center}
    .span-a{cursor: pointer;}
    .span-a:hover{color:#428bca}
    [v-cloak]{display:none}
    @keyframes blink {
        0% { border-color: rgba(30, 144, 255, 1) }
        50% { border-color: rgba(30, 144, 25, 0)}
        100% { border-color: rgba(30, 144, 255, 1) }
    }
    .blink{
        animation: blink 2s linear infinite
    }
</style>
<form action="<?php  echo aurl(5)?>" id="form" method="post" enctype="multipart/form-data">
<input name="token" type="hidden" value="<?php  echo $_W['token'];?>" />
<input type="hidden" name="id" value="<?php  echo $row['id'];?>" />
<div>

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#base" aria-controls="base" role="tab" data-toggle="tab">基本信息</a></li>
        <li role="presentation"><a href="#extend" aria-controls="extend" role="tab" data-toggle="tab">扩展选项</a></li>
        <li role="presentation"><a href="#attract" aria-controls="attract" role="tab" data-toggle="tab">招商设置</a></li>
        <li role="presentation"><a href="#redpack" aria-controls="redpack" role="tab" data-toggle="tab">返利设置</a></li>
        <li role="presentation"><a href="#joininformation" aria-controls="joininformation" role="tab" data-toggle="tab">订单信息采集</a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="base">
            
            <?php  if($_W['role'] != 'clerk') { ?>
            <div class="szxh-line">
                <span class="szxh-title">显示状态：</span>
                <span class="szxh-setting">
                    <div class="btn-group" data-toggle="buttons">
                        <label class="btn btn-info <?php  if($row['status'] == 1) { ?> active<?php  } ?>">
                            <input type="radio" name="status" value="1" id="option1" autocomplete="off" <?php  if($row['status'] == 1) { ?>checked<?php  } ?>> 审核中
                        </label>
                        <label class="btn btn-info <?php  if($row['status'] == 2 || empty($row['status'])) { ?> active<?php  } ?>">
                            <input type="radio" name="status" value="2" id="option1" autocomplete="off" <?php  if($row['status'] == 2 || empty($row['status'])) { ?>checked<?php  } ?>> 正常
                        </label>
                        <label class="btn btn-info <?php  if($row['status'] == 3) { ?> active<?php  } ?>">
                            <input type="radio" name="status" value="3" id="option2" autocomplete="off" <?php  if($row['status'] == 3) { ?>checked<?php  } ?>> 关闭
                        </label>
                    </div>
                </span>
            </div>
            <?php  } ?>
            
            <div class="szxh-line">
                <span class="szxh-title">所属类别：</span>
                <span class="szxh-setting">
                    <select class="form-control text-width-normal" name="active_cate_id">
                        <option value="0">请选择类别</option>
                        <?php  if(is_array($activeCates)) { foreach($activeCates as $cate) { ?>
                        <option value="<?php  echo $cate['id'];?>" <?php  if($row['active_cate_id'] == $cate['id']) { ?>selected<?php  } ?>><?php  echo $cate['title'];?></option>
                        <?php  } } ?>
                    </select>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">内容标题：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="title" value="<?php  echo $row['title'];?>">
                    <p class="help-block">标题最多100个字符</p>
                </span>
            </div>
            
            <div class="szxh-line">
                <span class="szxh-title">封面图片：</span>
                <span class="szxh-setting"><?php  echo tpl_form_field_image('cover', $row['cover'])?></span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">分享活动按钮：</span>
                <span class="szxh-setting">
                    <select class="form-control text-width-large" name="design_status" id="design_status">
                        <option value="1">关闭&emsp;</option>
                        <option value="2" <?php  if($row['design_status'] == 2) { ?>selected='selected'<?php  } ?>>点击显示分享图片&emsp;</option>
                        <option value="3" <?php  if($row['design_status'] == 3) { ?>selected='selected'<?php  } ?>>点击显示分享给朋友指示箭头&emsp;</option>
                        <option value="4" <?php  if($row['design_status'] == 4) { ?>selected='selected'<?php  } ?>>点击显示以上两种&emsp;</option>
                    </select>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">商品价格：</span>
                <span class="szxh-setting"><input type="number" class="form-control text-width-small" name="price" value="<?php  echo $row['price'];?>" step="0.01" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>> 元</span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">关联客服：</span>
                <span class="szxh-setting">
                    <select class="form-control text-width-normal" name="service_user_id" <?php  if($_W['role'] == 'clerk') { ?>disabled="disabled"<?php  } ?>>
                        <option value="0" >请选择客服</option>
                        <?php  if(is_array($serviceUsers)) { foreach($serviceUsers as $user) { ?>
                        <option value="<?php  echo $user['id'];?>" <?php  if($row['service_user_id'] == $user['id'] || $_W['uid'] == $user['uid']) { ?>selected<?php  } ?>><?php  echo $user['name'];?></option>
                        <?php  } } ?>
                    </select>
                    <?php  if($_W['role'] == 'clerk') { ?>
                        <input type="hidden" name="service_user_id" value="<?php  echo $_W['uid'];?>">
                    <?php  } ?>
                    <p class="help-block">客服选定之后不能再修改</p>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">内容描述：</span>
                <span class="szxh-setting limithigh"><?php  echo tpl_ueditor('content', $row['content'])?></span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">结束时间：</span>
                <span class="szxh-setting text-width-normal"><?php  echo _tpl_form_field_date('end_time', $row['end_time'])?></span>
            </div>

        </div>
        <div role="tabpanel" class="tab-pane" id="extend">

            <div class="szxh-line">
                <span class="szxh-title">开启核销：</span>
                <span class="szxh-setting">
                    <select class="form-control text-width-normal" name="is_cav" id="is_cav">
                        <option value="1">关闭</option>
                        <option value="2" <?php  if($row['is_cav'] == 2) { ?>selected='selected'<?php  } ?>>开启</option>
                    </select>
                    <p class="help-block">开启核销后，用户通过活动页面报名并支付成功，活动页面下方会出现【查看我的二维码】。该二维码在前往报名时出示给核销员使用。</p>
                </span>
            </div>
            
            <div class="szxh-line">
                <span class="szxh-title">活动小标题：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="second_title" value="<?php  echo $row['second_title'];?>" placeholder="我是%NAME%，我正在参加%TITLE%活动，快来加入我们吧~">
                    <p class="help-block">
                        最多100个字符，不能和活动标题内容相同。标题支持替换符：<br>
                        写入 %TITLE% ，将替换为当前活动标题；<br>
                        写入 %USER% ，将替换为分享人微信昵称；<br>
                        写入 %NAME% ，将替换为分享人下单姓名。
                    </p>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">页面设置：</span>
                <span class="szxh-setting">
                    <div>
                        红包排行榜显示用户个数：&emsp;<select name="redpack_show_number">
                            <option value="10" <?php  if($row['redpack_show_number'] == 10) { ?>selected="selected"<?php  } ?>>10个</option>
                            <option value="9" <?php  if($row['redpack_show_number'] == 9) { ?>selected="selected"<?php  } ?>>9个</option>
                            <option value="8" <?php  if($row['redpack_show_number'] == 8) { ?>selected="selected"<?php  } ?>>8个</option>
                            <option value="7" <?php  if($row['redpack_show_number'] == 7) { ?>selected="selected"<?php  } ?>>7个</option>
                            <option value="6" <?php  if($row['redpack_show_number'] == 6) { ?>selected="selected"<?php  } ?>>6个</option>
                            <option value="5" <?php  if($row['redpack_show_number'] == 5) { ?>selected="selected"<?php  } ?>>5个</option>
                            <option value="4" <?php  if($row['redpack_show_number'] == 4) { ?>selected="selected"<?php  } ?>>4个</option>
                            <option value="3" <?php  if($row['redpack_show_number'] == 3) { ?>selected="selected"<?php  } ?>>3个</option>
                            <option value="2" <?php  if($row['redpack_show_number'] == 2) { ?>selected="selected"<?php  } ?>>2个</option>
                            <option value="1" <?php  if($row['redpack_show_number'] == 1) { ?>selected="selected"<?php  } ?>>1个</option>
                            <option value="0" <?php  if($row['redpack_show_number'] == 0) { ?>selected="selected"<?php  } ?>>不显示&emsp;</option>
                        </select>
                    </div>
                    <br>
                    <div>
                        购买记录高度：&emsp;<select name="buyer_show_number">
                            <option value="5" <?php  if($row['buyer_show_number'] == 5) { ?>selected="selected"<?php  } ?>>5人高</option>
                            <option value="4" <?php  if($row['buyer_show_number'] == 4) { ?>selected="selected"<?php  } ?>>4人高</option>
                            <option value="3" <?php  if($row['buyer_show_number'] == 3) { ?>selected="selected"<?php  } ?>>3人高</option>
                            <option value="2" <?php  if($row['buyer_show_number'] == 2) { ?>selected="selected"<?php  } ?>>2人高</option>
                            <option value="1" <?php  if($row['buyer_show_number'] == 1) { ?>selected="selected"<?php  } ?>>1人高</option>
                            <option value="0" <?php  if($row['buyer_show_number'] == 0) { ?>selected="selected"<?php  } ?>>不显示购买记录</option>
                        </select>
                    </div>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">活动策划人：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control text-width-normal" name="planner" value="<?php  echo $row['planner'];?>">
                </span>
            </div>

          	<div class="szxh-line">
                <span class="szxh-title">机构地区：</span>
                <span class="szxh-setting">
                    <?php  echo tpl_districts('inst', $row['inst_province'], $row['inst_city'], $row['inst_district'])?>
                </span>
            </div>
          
            <div class="szxh-line">
                <span class="szxh-title">机构地区详细：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="inst" value="<?php  echo $row['inst'];?>">
                </span>
            </div>
          
            

            <div class="szxh-line">
                <span class="szxh-title">学校名称：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="school" value="<?php  echo $row['school'];?>">
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">收货人姓名：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control text-width-normal" name="consignee" value="<?php  echo $row['consignee'];?>">
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">收货人联系电话：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control text-width-normal" name="consignee_mobile" value="<?php  echo $row['consignee_mobile'];?>">
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">收货地址：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="consignee_addr" value="<?php  echo $row['consignee_addr'];?>">
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">货品：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="goods" value="<?php  echo $row['goods'];?>">
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">主礼品：</span>
                <span class="szxh-setting">
                    <select name="new_user_gift">
                        <option value="">礼品1&emsp;</option>
                        <?php  if(is_array($gifts1)) { foreach($gifts1 as $gift) { ?>
                            <option value="<?php  echo $gift;?>" <?php  if($row['new_user_gift'] == $gift) { ?>selected="selected"<?php  } ?>><?php  echo $gift;?>&emsp;</option>
                        <?php  } } ?>
                        <?php  if($row['new_user_gift']!='' && !in_array($row['new_user_gift'], $gifts1)) { ?>
                            <optgroup label="----请尽快修改----">
                            <option value="<?php  echo $row['new_user_gift'];?>" selected="selected"><?php  echo $row['new_user_gift'];?>&emsp;</option>
                            </optgroup>
                        <?php  } ?>
                    </select>
                    <select name="new_user_gift2">
                        <option value="">礼品2&emsp;</option>
                        <?php  if(is_array($gifts1)) { foreach($gifts1 as $gift) { ?>
                            <option value="<?php  echo $gift;?>" <?php  if($row['new_user_gift2'] == $gift) { ?>selected="selected"<?php  } ?>><?php  echo $gift;?>&emsp;</option>
                        <?php  } } ?>
                        <?php  if($row['new_user_gift2']!='' && !in_array($row['new_user_gift2'], $gifts1)) { ?>
                            <optgroup label="----请尽快修改----">
                            <option value="<?php  echo $row['new_user_gift2'];?>" selected="selected"><?php  echo $row['new_user_gift2'];?>&emsp;</option>
                            </optgroup>
                        <?php  } ?>
                    </select>
                    <select name="new_user_gift3">
                        <option value="">礼品3&emsp;</option>
                        <?php  if(is_array($gifts1)) { foreach($gifts1 as $gift) { ?>
                            <option value="<?php  echo $gift;?>" <?php  if($row['new_user_gift3'] == $gift) { ?>selected="selected"<?php  } ?>><?php  echo $gift;?>&emsp;</option>
                        <?php  } } ?>
                        <?php  if($row['new_user_gift3']!='' && !in_array($row['new_user_gift3'], $gifts1)) { ?>
                            <optgroup label="----请尽快修改----">
                            <option value="<?php  echo $row['new_user_gift3'];?>" selected="selected"><?php  echo $row['new_user_gift3'];?>&emsp;</option>
                            </optgroup>
                        <?php  } ?>
                    </select>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">附加礼品：</span>
                <span class="szxh-setting">
                    <select name="old_user_gift">
                        <option value="">礼品1&emsp;</option>
                        <?php  if(is_array($gifts2)) { foreach($gifts2 as $gift) { ?>
                            <option value="<?php  echo $gift;?>" <?php  if($row['old_user_gift'] == $gift) { ?>selected="selected"<?php  } ?>><?php  echo $gift;?>&emsp;</option>
                        <?php  } } ?>
                        <?php  if($row['old_user_gift']!='' && !in_array($row['old_user_gift'], $gifts2)) { ?>
                            <optgroup label="----请尽快修改----">
                            <option value="<?php  echo $row['old_user_gift'];?>" selected="selected"><?php  echo $row['old_user_gift'];?>&emsp;</option>
                            </optgroup>
                        <?php  } ?>
                    </select>
                    <select name="old_user_gift2">
                        <option value="">礼品2&emsp;</option>
                        <?php  if(is_array($gifts2)) { foreach($gifts2 as $gift) { ?>
                            <option value="<?php  echo $gift;?>" <?php  if($row['old_user_gift2'] == $gift) { ?>selected="selected"<?php  } ?>><?php  echo $gift;?>&emsp;</option>
                        <?php  } } ?>
                        <?php  if($row['old_user_gift2']!='' && !in_array($row['old_user_gift2'], $gifts2)) { ?>
                            <optgroup label="----请尽快修改----">
                            <option value="<?php  echo $row['old_user_gift2'];?>" selected="selected"><?php  echo $row['old_user_gift2'];?>&emsp;</option>
                            </optgroup>
                        <?php  } ?>
                    </select>
                    <select name="old_user_gift3">
                        <option value="">礼品3&emsp;</option>
                        <?php  if(is_array($gifts2)) { foreach($gifts2 as $gift) { ?>
                            <option value="<?php  echo $gift;?>" <?php  if($row['old_user_gift3'] == $gift) { ?>selected="selected"<?php  } ?>><?php  echo $gift;?>&emsp;</option>
                        <?php  } } ?>
                        <?php  if($row['old_user_gift3']!='' && !in_array($row['old_user_gift3'], $gifts2)) { ?>
                            <optgroup label="----请尽快修改----">
                            <option value="<?php  echo $row['old_user_gift3'];?>" selected="selected"><?php  echo $row['old_user_gift3'];?>&emsp;</option>
                            </optgroup>
                        <?php  } ?>
                    </select>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">客服电话：</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control text-width-normal" name="service_tel" value="<?php  echo $row['service_tel'];?>">
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">背景音乐：</span>
                <span class="szxh-setting">
                    <?php  echo tpl_form_field_audio('bgm', $row['bgm'])?>
                </span>
            </div>
        </div>

        <div role="tabpanel" class="tab-pane" id="attract">

            <div class="szxh-line">
                <span class="szxh-title">是否开启招商</span>
                <span class="szxh-setting">
                    <select name="attract_status" id="attract_status">
                        <option value="1" <?php  if($row['attract_status'] == 1) { ?>selected="selected"<?php  } ?>>开启&emsp;</option>
                        <option value="2" <?php  if($row['attract_status'] == 2) { ?>selected="selected"<?php  } ?>>关闭&emsp;</option>
                    </select>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">招商文字</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="attract_title" value="<?php echo $row['attract_title'] ?: '创建我的活动'?>">
                </span>
            </div>
            
            <div class="szxh-line">
                <span class="szxh-title">显示方式</span>
                <span class="szxh-setting">
                    <select name="attract_type" id="attract_type">
                        <option value="1" <?php  if($row["attract_type"] == 1) { ?>selected="selected"<?php  } ?>>客服二维码&emsp;</option>
                        <option value="2" <?php  if($row["attract_type"] == 2) { ?>selected="selected"<?php  } ?>>自定义跳转链接&emsp;</option>
                        <option value="3" <?php  if($row["attract_type"] == 3) { ?>selected="selected"<?php  } ?>>自定义内容&emsp;</option>
                    </select>
                </span>
            </div>

            <div class="szxh-line">
                <span class="szxh-title">自定义跳转链接</span>
                <span class="szxh-setting">
                    <input type="text" class="form-control" name="attract_value_link" value="<?php  echo $row['attract_value_link'];?>" placeholder="http(s)://">
                    <span class="help-block">显示方式选择自定义跳转链接时必填此项。</span>
                </span>
            </div>
            
            <div class="szxh-line">
                <span class="szxh-title">自定义内容</span>
                <span class="szxh-setting limithigh">
                    <?php  echo tpl_ueditor('attract_value_custom', $row['attract_value_custom'])?>
                    <span class="help-block">显示方式选择自定义内容时必填此项。</span>
                </span>
            </div>

        </div>

        <div role="tabpanel" class="tab-pane" id="redpack">

            <div class="szxh-line">
                <span class="szxh-title">返利功能：</span>
                <span class="szxh-setting">
                    <select class="form-control text-width-normal" name="redpack_status" id="redpack_status" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
                        <option value="1">开启</option>
                        <option value="2" <?php  if($row['redpack_status'] == 2) { ?>selected='selected'<?php  } ?>>关闭</option>
                    </select>
                    <p class="help-block">1. 开启微信返利时，需要在微擎 平台-支付参数-退款配置-微信退款 中上传证书并保存</p>
                </span>
            </div>

            <div id="show_redpack_config"></div>
            

        </div>

        <div role="tabpanel" class="tab-pane" id="joininformation" v-cloak >
        
            <div class="szxh-line">
                <span class="szxh-title">开启信息采集</span>
                <span class="szxh-setting">
                    <select name="joininformation_status">
                        <option value="1" <?php  if($row['joininformation_status'] == 1) { ?>selected="selected"<?php  } ?>>开启&emsp;</option>
                        <option value="2" <?php  if($row['joininformation_status'] == 2) { ?>selected="selected"<?php  } ?>>关闭&emsp;</option>
                    </select>
                    &emsp; <a href="javascript:;" v-if="joininformation.length < 5" @click="addRow" style="margin-left:10px;text-decoration:underline;color:dodgerblue">增加</a>
                    <input type="hidden" name="joininformation" value='<?php  echo $row["joininformation"];?>' v-model="json"><br><br>
                    <label><input type="checkbox" value="1" v-model="useOpt"> 启用预设采集订单信息（姓名+电话+身份类型）（与下方设置的自定义信息共存，请注意。）</label><br><br>
                </span>
                
            </div>
            <div class="szxh-line" v-if="joininformation.length > 0">
                
                <span class="szxh-title"></span>
                <span class="szxh-setting">
                <div class="joininformation">
                    <div v-for="jim in joininformation" v-if="jim.opt == false || jim.opt == undefined" style="margin-bottom:20px">
                        <div class="joininformation-item">
                            <div class="joininformation-line1">
                                <span class="joininformation-title"><input type="text" class="form-control" v-model="jim.name"></span>
                                <span class="joininformation-box"><label style="vertical-align:super"><input type="radio" value="1" v-model="jim.type"> 选择输入框</label></span>
                            </div>
                            <div class="joininformation-tip">
                                <input type="text" class="form-control" v-model="jim.placeholder" style="height:24px;margin:5px 0;color:#999">
                            </div>
                            <div class="joininformation-action">
                                <a href="javascript:;" style="font-size:12px;margin-left:10px;"
                                    @click="deleteRow(jim)">删除</a>
                            </div>
                        </div>
                        <div class="joininformation-extend">
                            <label style="line-height:10px;margin-bottom:22px"><input type="radio" value="2" v-model="jim.type"> 选择下拉菜单&emsp;<span class="span-a" @click="addSelect(jim)">添加</span></label>
                            <div style="text-align: center" v-for="select in jim.select">
                                <span><input type="text" v-model="select.name"></span>
                                <!-- <span><label style="vertical-align: baseline;"><input type="checkbox" value="1" v-model="select.nopay"> 不需要支付</label></span> -->
                                <span><a href="javascript:;" @click="removeSelect(jim, select)">删除</a></span>
                            </div>
                        </div>
                        <div style="clear:both"></div>
                    </div>
                </div>
                </span>
            </div>
            
        
            <div class="szxh-line">
                <span class="szxh-title"></span>
                <span class="szxh-setting">
                    <p class="help-block">设置项目最多4个字，提示信息最多10个字。仅填写的项在活动页面展示。</p>
                </span>
            </div>
            
        </div>

    </div>
    <div class="szxh-line"><span class="szxh-title"></span><span class="szxh-setting"><button type="submit" class="btn btn-info">提交保存</button></span></div>

</div>
</form>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('base/js', TEMPLATE_INCLUDEPATH)) : (include template('base/js', TEMPLATE_INCLUDEPATH));?>
<script type="text/html" id="redpack_config">
    <div class="szxh-line">
        <span class="szxh-title">推荐返利设置：</span>
        <span class="szxh-setting">
            朋友支付后，推荐人
            <select class="form-control text-width-small" name="redpack_ispay" id="redpack_ispay" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
                <option value="1">支付完成后</option>
                <option value="2" <?php  if($row['redpack_ispay'] == 2) { ?>selected='selected'<?php  } ?>>报名成功后&emsp;</option>
                <option value="3" <?php  if($row['redpack_ispay'] == 3) { ?>selected='selected'<?php  } ?>>无需报名&emsp;</option>
                <option value="4" <?php  if($row['redpack_ispay'] == 4) { ?>selected='selected'<?php  } ?>>不获得奖励&emsp;</option>
            </select>
            <span>
                ，推荐人获得 
                <input type="number"  class="form-control text-width-tiny" name="min_get" value="<?php  echo $row['min_get'];?>" maxlength="2" step="1" min="0" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
                -
                <input type="number" class="form-control text-width-tiny" name="max_get" value="<?php  echo $row['max_get'];?>" maxlength="2" step="1" min="0" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
             元随机红包奖励
            </span>
            <p class="help-block">红包金额必须填写整数范围。</p>
        </span>
    </div>
    <div class="szxh-line">
        <span class="szxh-title">分享返利设置：</span>
        <span class="szxh-setting">
            自己在<select class="form-control text-width-small" name="share_ispay" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
                    <option value="1">支付完成后</option>
                    <option value="2" <?php  if($row['share_ispay'] == 2) { ?>selected='selected'<?php  } ?>>报名成功后&emsp;</option>
                    <option value="3" <?php  if($row['share_ispay'] == 3) { ?>selected='selected'<?php  } ?>>无需报名&emsp;</option>
                </select>分享
            <select class="form-control text-width-tiny" name="share_reward_count" id="share_reward_count" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
                <option value="0">0</option>
                <option value="1" <?php  if($row['share_reward_count'] == 1) { ?>selected='selected'<?php  } ?>>1&emsp;</option>
                <option value="2" <?php  if($row['share_reward_count'] == 2) { ?>selected='selected'<?php  } ?>>2&emsp;</option>
                <option value="3" <?php  if($row['share_reward_count'] == 3) { ?>selected='selected'<?php  } ?>>3&emsp;</option>
                <option value="4" <?php  if($row['share_reward_count'] == 4) { ?>selected='selected'<?php  } ?>>4&emsp;</option>
                <option value="5" <?php  if($row['share_reward_count'] == 5) { ?>selected='selected'<?php  } ?>>5&emsp;</option>
                <option value="6" <?php  if($row['share_reward_count'] == 6) { ?>selected='selected'<?php  } ?>>6&emsp;</option>
                <option value="7" <?php  if($row['share_reward_count'] == 7) { ?>selected='selected'<?php  } ?>>7&emsp;</option>
                <option value="8" <?php  if($row['share_reward_count'] == 8) { ?>selected='selected'<?php  } ?>>8&emsp;</option>
                <option value="9" <?php  if($row['share_reward_count'] == 9) { ?>selected='selected'<?php  } ?>>9&emsp;</option>
                <option value="10" <?php  if($row['share_reward_count'] == 10) { ?>selected='selected'<?php  } ?>>10&emsp;</option>
                <option value="11" <?php  if($row['share_reward_count'] == 11) { ?>selected='selected'<?php  } ?>>11&emsp;</option>
                <option value="12" <?php  if($row['share_reward_count'] == 12) { ?>selected='selected'<?php  } ?>>12&emsp;</option>
                <option value="13" <?php  if($row['share_reward_count'] == 13) { ?>selected='selected'<?php  } ?>>13&emsp;</option>
                <option value="14" <?php  if($row['share_reward_count'] == 14) { ?>selected='selected'<?php  } ?>>14&emsp;</option>
                <option value="15" <?php  if($row['share_reward_count'] == 15) { ?>selected='selected'<?php  } ?>>15&emsp;</option>
                <option value="16" <?php  if($row['share_reward_count'] == 16) { ?>selected='selected'<?php  } ?>>16&emsp;</option>
                <option value="17" <?php  if($row['share_reward_count'] == 17) { ?>selected='selected'<?php  } ?>>17&emsp;</option>
                <option value="18" <?php  if($row['share_reward_count'] == 18) { ?>selected='selected'<?php  } ?>>18&emsp;</option>
                <option value="19" <?php  if($row['share_reward_count'] == 19) { ?>selected='selected'<?php  } ?>>19&emsp;</option>
                <option value="20" <?php  if($row['share_reward_count'] == 20) { ?>selected='selected'<?php  } ?>>20&emsp;</option>
            </select>
            次给朋友或朋友圈，获得 <input type="text" name="share_reward" value="<?php  echo $row['share_reward'];?>" class="form-control text-width-tiny" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>> 元红包
            
            
            <p class="help-block">
                1. 必须开启分享后设置的金额才能生效。<br>
                2. 分享红包<span style="color:red">金额必须在微信授权发放金额范围内</span>，不然不会生效。<br>
                3. 已获得红包的用户不再获得红包。<br>
                4. 次数填写0的依旧不会生效
                <!-- <span style="color:red;font-size:16px">4. 使用微信在6.7.2及以上版本由于分享不稳定暂不支持【分享给好友】和【分享到朋友圈】功能，新版微信请通过活动下方的【分享活动马上赚钱】参与活动返利。</span> -->
            </p>
        </span>
    </div>
    <div class="szxh-line">
        <span class="szxh-title">返利给校长：</span>
        <span class="szxh-setting">
            <input type="number"  class="form-control text-width-small" name="princ_reward" value="<?php  echo $row['princ_reward'];?>" step="0.01" min="0" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
            单位：元，最低1元，否则返利不会生效
        </span>
    </div>
    <div class="szxh-line">
        <span class="szxh-title">发放形式：</span>
        <span class="szxh-setting">
            <select class="form-control text-width-normal" name="redpack_type" id="redpack_type" onchange="showTransfers(this.value)" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
                <option value="1">微信现金红包</option>
                <option value="2" <?php  if($row['redpack_type'] == 2) { ?>selected='selected'<?php  } ?>>微信企业付款</option>
            </select>
            <p class="help-block">选择微信企业付款时，只需填写发送备注即可</p>
        </span>
    </div>
    <div id="show_redpack_transfers_info"></div>
</script>
<script type="text/html" id="redpack_info">
    <div class="szxh-line">
        <span class="szxh-title">活动名称：</span>
        <span class="szxh-setting">
            <input type="text" class="form-control text-width-normal" name="redpack_name" value="<?php  echo $row['redpack_name'];?>" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
            <p class="help-block">不超过10个字</p>
        </span>
    </div>
    <div class="szxh-line">
        <span class="szxh-title">发送人名称：</span>
        <span class="szxh-setting">
            <input type="text" class="form-control text-width-normal" name="redpack_sender" value="<?php  echo $row['redpack_sender'];?>" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
        </span>
    </div>
    <div class="szxh-line">
        <span class="szxh-title">红包祝福语：</span>
        <span class="szxh-setting">
            <input type="text" class="form-control" name="redpack_wishing" value="<?php  echo $row['redpack_wishing'];?>" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
        </span>
    </div>
    <div class="szxh-line">
        <span class="szxh-title">发放备注：</span>
        <span class="szxh-setting">
            <input type="text" class="form-control" name="redpack_remark" value="<?php  echo $row['redpack_remark'];?>" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
        </span>
    </div>
</script>
<script type="text/html" id="transfers_info">
    <div class="szxh-line">
        <span class="szxh-title">转账备注信息：</span>
        <span class="szxh-setting">
            <input type="text" class="form-control" name="transfers_remark" value="<?php  echo $row['transfers_remark'];?>" <?php  if($_W['role'] == 'clerk' && !empty($row['id'])) { ?>disabled="disabled"<?php  } ?>>
        </span>
    </div>
</script>

<script>
    $('#form').on('submit', function(e) {
        
        var data = $(this).serialize();
        // TODO
        post('<?php  echo aurl(5)?>', data, function() {
            setTimeout(function() {
                location.href = "<?php  echo aurl(1)?>";
            }, 2000);
        });

        return false;
    })

    showRedpackConfig($('#redpack_status').val() == 1);
    $('#redpack_status').on('change', function() {
        showRedpackConfig($('#redpack_status').val() == 1);
    })

    function showRedpackConfig(show) {
        var html = '';
        if(show) {
            html = $('#redpack_config').html();
        }
        $('#show_redpack_config').html(html);
        showTransfers($('#redpack_type').val());
    }

    function showTransfers(show) {
        if(show == 1) {
            $('#show_redpack_transfers_info').html($('#redpack_info').html());
        }
        if(show == 2) {
            $('#show_redpack_transfers_info').html($('#transfers_info').html());
        }
    }

</script>

<script>
    require.config({
        paths: {
            'Vue': '<?php echo WEB_RESOURCE;?>/library/vue'
        }
    });
    require(['Vue'], function(Vue) {
        function conversionJson(data) {
            try {
                return JSON.stringify(data);
            } catch (error) {
                return '';
            }
        }
        new Vue({
            el: '#joininformation',
            data: {
                joininformation: joininformation,
                json: '<?php  echo $row["joininformation"];?>',
                useOpt: false,
                opt1: {"name":"您的姓名","placeholder":"您的真实姓名","type":1,"select":[{"name":"","nopay":false}],'opt':'name'},
                opt2: {"name":"手机号码","placeholder":"11位手机号码","type":1,"select":[{"name":"","nopay":false}],'opt':'mobile'},
                opt3: {"name":"身份类型","placeholder":"请选择类型","type":"2","select":[{"name":"新学（会）员","nopay":false,"value":1},{"name":"老学（会）员","nopay":false,"value":2},{"name":"推广员/老师/工作人员（不享受优惠）","nopay":true,"value":3}],'opt':'type'}
            },
            mounted: function() {
                try {
                    this.joininformation = JSON.parse(this.json);
                } catch (error) {
                    this.joininformation = [];
                }
                if(this.json == '') {
                    this.useOpt = true;
                }
                for(var i in this.joininformation) {
                    if(this.joininformation[i].opt != false) {
                        this.useOpt = true;
                        break;
                    }
                }
            },
            methods: {
                deleteRow: function(el) {
                    this.joininformation.splice(this.joininformation.indexOf(el), 1);
                },
                addRow: function() {
                    this.joininformation.push({
                        name: '',
                        placeholder: '',
                        type: 1,
                        select: [
                            {name: '',nopay: false,value:''},
                        ],
                        opt: false
                    });
                },
                addSelect: function(jim) {
                    if(jim.select.length > 15) {
                        alert('最多添加15项');
                        return false;
                    }
                    jim.select.push({
                        name: '',
                        nopay: false,
                        value: ''
                    });
                },
                removeSelect: function(jim, select) {
                    if(jim.select.length == 1) {
                        alert('至少保留1项');
                        return;
                    }
                    jim.select.splice(jim.select.indexOf(select), 1);
                }
            },
            watch: {
                useOpt: function(val) {
                    if(this.joininformation.length > 0) {
                        for(var i = this.joininformation.length - 1; i >= 0; i--) {
                            if(this.joininformation[i].opt != false) {
                                this.joininformation.splice(this.joininformation.indexOf(this.joininformation[i]), 1);
                            }
                        }
                    }
                    if(val) {
                        this.joininformation.unshift(this.opt3);
                        this.joininformation.unshift(this.opt2);
                        this.joininformation.unshift(this.opt1);
                    }
                },
                joininformation: {
                    handler(newValue, oldValue) {
                        for(var jim in newValue) {
                            if(newValue[jim].opt != false) {
                                this.opt = true;
                                break;
                            }
                        }
                        this.json = conversionJson(this.joininformation);
                    },
                    deep: true
                }
            }
        });

    });
</script>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>